import java.io.*;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @author zhangrui
 * @date 2020-04-12 21:48
 */
public class Test {

    private static HashSet<String> set = new HashSet<>();
    private static List<String> list = new ArrayList<>();

    public static void initSet() {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("top.txt")),
                    "UTF-8"));
            String lineTxt = null;
            while ((lineTxt = br.readLine()) != null) {
                set.add(lineTxt.trim());
            }
            br.close();
        } catch (Exception e) {
            System.err.println("read errors :" + e);
        }
    }

    public static void initList(){
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("result100.txt")),
                    "UTF-8"));
            String lineTxt = null;
            while ((lineTxt = br.readLine()) != null) {
                list.add(lineTxt.trim());
            }
            br.close();
        } catch (Exception e) {
            System.err.println("read errors :" + e);
        }
    }

    public static void main(String[] args) {
        initSet();
        initList();

        int count = 0;
        for(String ss : list){
            if(set.contains(ss)){
                System.out.println(++count + ss);
            }
        }
    }
}
